package com.qf.commo.utils;

import com.alibaba.fastjson.JSON;
import org.springframework.http.MediaType;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ResponceUitls {
    public static void out(HttpServletResponse response,R r){
        //设置响应数据类型是JSON
        response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
        try {
            PrintWriter writer = response.getWriter();
            writer.write(JSON.toJSONString(r));
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
